﻿/*
*	全国三级城市联动 js版
*/
function Dsy(){
	this.Items = {};
}
Dsy.prototype.add = function(id,iArray){
	this.Items[id] = iArray;
}
Dsy.prototype.Exists = function(id){
	if(typeof(this.Items[id]) == "undefined") return false;
	return true;
}

function change(v){
	var str="0";
	for(i=0;i<v;i++){
		str+=("_"+(document.getElementById(s[i]).selectedIndex-1));
	};
	var ss=document.getElementById(s[v]);
	with(ss){
		length = 0;
		options[0]=new Option(opt0[v],opt0[v]);
		if(v && document.getElementById(s[v-1]).selectedIndex>0 || !v){
			if(dsy.Exists(str)){
				ar = dsy.Items[str];
				for(i=0;i<ar.length;i++){
					options[length]=new Option(ar[i],ar[i]);
				}//end for
				if(v){ options[0].selected = true; }
			}
		}//end if v
		if(++v<s.length){change(v);}
	}//End with
}

var dsy = new Dsy();

dsy.add("0",["一汽奥迪","东风英菲尼迪","夏利","奇瑞","奥迪","庆铃","日产","比亚迪"]);
dsy.add("0_0",["奥迪Q3","Q5","奥迪Q5","奥迪A4","奥迪A6"]);
dsy.add("0_0_0",["1.4T","2.0T"]);
dsy.add("0_0_1",["2.0T"]);
dsy.add("0_0_2",["2.0T"]);
dsy.add("0_0_3",["2.0T"]);
dsy.add("0_0_4",["2.8T"]);
dsy.add("0_0_0_0",["手动挡","双离合变速器"]);
dsy.add("0_0_0_1",["手动挡","双离合变速器"]);
dsy.add("0_0_1_0",["双离合变速器","手自一体"]);
dsy.add("0_0_2_0",["手动挡","双离合变速器"]);
dsy.add("0_0_3_0",["双离合变速器","手自一体"]);
dsy.add("0_0_4_0",["手动挡","双离合变速器"]);
dsy.add("0_0_0_0_0",["FV7145LCMAG","FV7145LCMBG","FV7145LCDAG","FV7145LCDBG","FV7145LADBG"]);
dsy.add("0_0_0_0_1",["FV7145LCMAG","FV7145LCMBG","FV7145LCDAG","FV7145LCDBG","FV7145LADBG"]);
dsy.add("0_0_0_0_2",["FV7145LCMAG","FV7145LCMBG","FV7145LCDAG","FV7145LCDBG","FV7145LADBG"]);
dsy.add("0_0_0_0_0_0",["奥迪FV7145LCMAG轿车 手动挡 2014款30TFSI标准型 5座（参考价199800）"]);
dsy.add("0_1",["东风英菲尼迪Q50L","东风英菲尼迪QX50"]);
dsy.add("0_1_0",["1.4T","2.0T"]);
dsy.add("0_1_0_0",["手自一体"]);
dsy.add("0_1_0_0_0",["DFL7205ASL2","DFL7205ASL1","DFL7205ASL3","DFL7205ASL4","DFL7205ASL5"]);
dsy.add("0_1_0_0_0_0",["英菲尼迪DFL7205ASL2轿车 手自一体 2016款 悦动版 5座（参考价289800）","英菲尼迪DFL7205ASL2轿车 手自一体 2016款 悦享版 5座（参考价309800）","英菲尼迪DFL7205ASL2轿车 手自一体 2016款 悦享版 5座（参考价279800）"]);

dsy.add("0_2",["夏利"]);
dsy.add("0_2_0",["1.4T"]);
dsy.add("0_2_0_0",["手动挡"]);
dsy.add("0_2_0_0_0",["TJ7141AU","TJ7141A"]);
dsy.add("0_2_0_0_0_0",["夏利TJ7141AU轿车 手动挡 2005款-QH A+/助力 5座（参考价47800）","夏利TJ7141AU轿车 手动挡 2005款-QH A+ 5座（参考价42800）"]);
var s=["s_brand","s_car","s_discharge","s_manual","s_carcode","s_model"];//三个select的name
var opt0 = ["请选择品牌","请选择车款","请选择排气量","请选择手动自动","请选择车型代码","请选择车辆型号"];//初始值
function _init_area(){  //初始化函数
	for(i=0;i<s.length-1;i++){
	  document.getElementById(s[i]).onchange=new Function("change("+(i+1)+")");
	}
	change(0);
}
